import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        userId: '',
        role: '',
        city: '全国站',
        email: '',
        password: '',
    },
    mutations: {
        initialState(state, payload) {
            state.userId = payload.id
            state.role = payload.role
            console.log('state.userId',state.userId);
            console.log('state.role',state.role);
        },
        setCity(state, payload) {
            state.city = payload.city
        },
        getUserId(state){
            console.log('inner state.userId',state.userId);
        },
        changeUserId(state,userId){
            state.userId = userId;
            console.log('state.userId',state.userId);
        },
        setLoginInfo(state,payload){
            state.email = payload.email
            state.password = payload.password
            console.log("payload:",payload);
            console.log("this.email:",state.email,'this.password:',state.password);
        }
    },
    // actions:{
    //     changeUserId(state,userId){
    //         state.userId = userId;
    //         console.log('state.userId',state.userId);
    //     },
    // }
})

export default store